using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace Eve.API
{
    /// <summary>
    /// Represents audit information about a corporation member.
    /// </summary>
    /// <remarks>
    /// The information provided by the <b>MemberTracking</b> class is similar to the information provided by
    /// the Corporation\Members windows in-game.
    /// </remarks>
    [Serializable]
    public class MemberTracking
    {
        private NameId character;
        private DateTime startTime;
        private NameId _base;
        private string title;
        private DateTime logonTime;
        private DateTime logoffTime;
        private NameId location;
        private NameId shipType;
        private long roles;
        private long grantableRoles;
        /// <summary>
        /// Gets the character name and identifier.
        /// </summary>
        /// <value>
        /// The character name and Eve internal identifier.
        /// </value>
        public NameId Character
        {
            get { return character; }
        }
        /// <summary>
        /// Gets the date the character joined the corporation.
        /// </summary>
        /// <value>
        /// The date the character joined the corporation.
        /// </value>
        public DateTime JoinDate
        {
            get { return startTime; }
        }
        /// <summary>
        /// Gets the name and identifier of the character's base station.
        /// </summary>
        /// <value>
        /// The name and Eve internal identifier of the character's base station.
        /// </value>
        public NameId Base
        {
            get { return _base; }
        }
        /// <summary>
        /// Gets the character's title.
        /// </summary>
        /// <value>
        /// The character's title.
        /// </value>
        public string Title
        {
            get { return title; }
        }
        /// <summary>
        /// Gets the last time the character logged on.
        /// </summary>
        /// <value>
        /// The last time the character logged on.
        /// </value>
        public DateTime Logon
        {
            get { return logonTime; }
        }
        /// <summary>
        /// Gets the last time the character logged off.
        /// </summary>
        /// <value>
        /// The last time the character logged off.
        /// </value>
        public DateTime Logoff
        {
            get { return logoffTime; }
        }
        /// <summary>
        /// Gets the name and identifier of the character's current location.
        /// </summary>
        /// <value>
        /// The name and Eve internal identifier of the character's current location.
        /// </value>
        public NameId Location
        {
            get { return location; }
        }
        /// <summary>
        /// Gets the name and type identifier of the ship that the character is piloting.
        /// </summary>
        /// <value>
        /// The name and Eve internal type identifier of the ship the character is piloting.
        /// </value>
        /// <remarks>
        /// The type identifier of the ship can be used with the <b>Eve.Data</b> class library to retrieve more detailed
        /// information about the ship type.
        /// </remarks>
        public NameId ShipType
        {
            get { return shipType; }
        }
        /// <summary>
        /// Gets a mask of the roles that the character has permissions for.
        /// </summary>
        /// <value>
        /// A mask of roles that the character has permissions for.
        /// </value>
        public long Roles
        {
            get { return roles; }
        }
        /// <summary>
        /// Gets a mask of the roles that the character can grant.
        /// </summary>
        /// <value>
        /// A mask of the roles that the character can grant.
        /// </value>
        public long GrantableRoles
        {
            get { return grantableRoles; }
        }

        internal MemberTracking(XmlElement mt)
        {
            character.Id = int.Parse(mt.Attributes["characterID"].Value);
            character.Name = mt.Attributes["name"].Value;
            startTime = DateTime.Parse(mt.Attributes["startDateTime"].Value);
            _base.Id = int.Parse(mt.Attributes["baseID"].Value);
            _base.Name = mt.Attributes["base"].Value;
            title = mt.Attributes["title"].Value;
            logonTime = DateTime.Parse(mt.Attributes["logonDateTime"].Value);
            logoffTime = DateTime.Parse(mt.Attributes["logoffDateTime"].Value);
            location.Id = int.Parse(mt.Attributes["locationID"].Value);
            location.Name = mt.Attributes["location"].Value;
            shipType.Id = int.Parse(mt.Attributes["shipTypeID"].Value);
            shipType.Name = mt.Attributes["shipType"].Value;
            roles = long.Parse(mt.Attributes["roles"].Value);
            grantableRoles = long.Parse(mt.Attributes["grantableRoles"].Value);
        }
    }
}
